<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .area{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            width: 200px;
            height: 300px;
            background-color: green;
        }
        .mask{
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            background-color: #000;
            opacity: 0.5;
            color: #fff;
            font-size: 100px;
        }
    </style>
</head>

<body>
    <div id="root"></div>
    <div id="hello"></div>
</body>

</html>
<script src="https://unpkg.com/vue@next"></script>
<script>
    // teleport  传送门
    const app = Vue.createApp({
        data(){
            return{
                show:false,
                message:"hello"
            }
        },
        methods:{
            handleClick(){
                this.show=!this.show
            }
        },
        template: `
        <div class="area">
            <button @click="handleClick">按钮</button>
            <teleport to="#hello">
                <div class="mask" v-show="show">{{message}}</div>
            </teltport>
        </div>
        `
    })
    const vm = app.mount('#root')
</script>